using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using buildingLib;

namespace _dmis
{
    public partial class MemberEdit : _dmis.WinPart
    {
        Member m_member;
        Owner m_owner;
        public Member Member
        {
            get { return m_member; }
        }
       
        public MemberEdit(Member member,Owner owner)
        {
            InitializeComponent();
            m_member = member;
            m_owner = owner;
            this.memberBindingSource.DataSource = m_member;
        }

        #region WinPart Code

        protected internal override object GetIdValue()
        {
            return m_member;
        }

        public override string ToString()
        {
            return m_member.OwnerID.ToString();
        }

        private void ResourceEdit_CurrentPrincipalChanged(object sender, EventArgs e)
        {
            ApplyAuthorizationRules();
        }
        #endregion

        private void ApplyAuthorizationRules()
        {
            // have the controls enable/disable/etc
           /* this.ReadWriteAuthorization1.ResetControlAuthorization();

            bool canEdit = ProjectTracker.Library.Project.CanEditObject();

            // enable/disable appropriate buttons
            this.OKButton.Enabled = canEdit;
            this.ApplyButton.Enabled = canEdit;
            this.Cancel_Button.Enabled = canEdit;

            // enable/disable role column in grid
            this.AssignmentsDataGridView.Columns[3].ReadOnly = !canEdit;*/
        }

        private void tsb_close_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void tsb_save_Click(object sender, EventArgs e)
        {
            m_owner.RelationMembers.Add(m_member);
            this.Close();
        }

        private void MemberEdit_Load(object sender, EventArgs e)
        {
            gendersBindingSource.DataSource = Genders.GetGenders();
        }
    }
}

